<?php
namespace app\index\controller;
use think\Controller;

class Home extends Logincheck{
    function index() {
        $x = model('xitong')->findid(1);
        $this->assign('x',$x);
        return $this->fetch(); 
    }
    // function jiangrate(){
    //     $datatime = model('openplate')->finddata();
        
    //     $res = model('orders')->where(['bet'=>$bet,'datatime'=>$datatime])->select();
      

    // }
    function home(){
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
         foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(3);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    function login1(){
        session("client",null);
        $this->redirect("index/index/index");
    }
    function jrate(){
        // 自动降赔率函数
        $opent = model('openplate')->findall();
        foreach($opent as $key =>$o){
            // 找今期账单
            if(time() >= $o['opentime'] && time() <= $o['tclosetime'] ){
                $datatime = $o['datetime'];
            }
        }
        $order = model('ordered')->findallorder($datatime);
        
    }
    //下注状况 
    function condition(){
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
         foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        
        $datatime = model('openplate')->finddatename();
        $order = model("ordered")->finduserprice(session('userid'),$datatime);
        
        $ordernumber = count($order);
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $orderwin = 0;
        $pirces = 0;
        foreach ($order as $k => $vae) {
            $orderwin += $order[$k]['win'];
            $prices += (int)$order[$k]['price'];
        }
        
        $this->assign('prices',$prices);
        $this->assign('winpirce',$orderwin);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('orders',$orders);
        $this->assign('order',$order);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        $this->assign('ordernumber',$ordernumber);
        // mp($order);
        return $this->fetch(); 
    }
    function panduanplate(){
        // 特码或者其他玩法是否开盘
        $opent = model('openplate')->openttype();
        if($opent==0){
             $this->redirect("index/home/home"); 
        }
        $s = model('openplate')->tfindopent();
        return $s;
    }
    function openzmplate(){
        // 四种正码是否开盘
        $opent = model('openplate')->openttype();
         if($opent==0){
             $this->redirect("index/home/home"); 
        }
        $s = model('openplate')->zfindopent();
        return $s;
    }
    // 客服
    function Customer(){
        $page = $_GET['page'];
        if($page<1){
            $page = 1;
        }
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $result = model('kefu')->finduser(session('userid'),$page);
        $orders = model('Orders')->findsid(session('userid'));
         foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('orders',$orders);
        $this->assign('result',$result);
        $this->assign('page',$page );
        $this->assign('user',$user);
        $this->assign('Characters',$Characters);
       return $this->fetch();  
    }
    // 盘口判断截取接口
    function charactersubstr($Character){
        $Characters['c1'] = substr($Character,0,1);
        $Characters['c2'] = substr($Character,1,1);
        $Characters['c3'] = substr($Character,2,1);
        $Characters['c4'] = substr($Character,3,1);
        return $Characters;
    }
    
    // 会员资料
    function data(){
        model('user')->where('id',session('userid'))->update(['addrs'=>20]);
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
         foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $res = model('returnwater')->findts(session('userid'));
        
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        // mp($qishu);
        return $this->fetch(); 
    }       
    // 账户历史
    function history($stime=0,$etime=0){
        model('user')->where('id',session('userid'))->update(['addrs'=>18]);
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
         foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $qishu = model('openplate')->findqishu();
        $this->assign('datetime',$datetime);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);



        $this->getHistory($stime,$etime);
        return $this->fetch(); 
    }
    function getHistory($stime,$etime){
        if($stime){
            $stime = strtotime($stime);
        }else{
            $stime = 0;
        }
        if($etime){
            $etime = strtotime($etime);
        }else{
            $etime = time();
        }
        $tj = db("profzb")->where("uid",session('userid'))->select();
        $data = [];
        for ($i=0;$i<count($tj);$i++) {
            $item = $tj[$i];
            $order = db("orders")->find($item['orders_id']);
            $ordered = db("ordered")->find($order['order_id']);
            $tj[$i]['datatime'] = $ordered['datatime'];
            $tj[$i]['times'] = date("Y-m-d",$ordered['times']);
            if($ordered['times']<$stime){
                continue;
            }
            if(!$etime || $ordered['times']>$etime){
                continue;
            }
            $data[] = $tj[$i];
        }
        $this->assign("tj",$data);
    }
    // 规则说明
    function instrction(){
        model('user')->where('id',session('userid'))->update(['addrs'=>19]);
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $xitong = model('xitong')->findid(2);
        $this->assign('xt',$xitong);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    function lottery(){
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }

    // 特码
    function member1($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>24]);
        $s = $this->panduanplate();
        $stime = time();
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $resultA = model("rate")->findrateA(1);
        $num = model("pancha")->findpan(1);
        // $jrate1 = model('jiangrate')->jrate1_4();
        // $jrate2 = model('jiangrate')->jrate19_21();
        for ($i=0; $i <=49 ; $i++) { 
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               $num1_49 = $num['andicapB'];
            }
            if($andicap==3){
               $num1_49 = $num['andicapC'];
            }
            if($andicap==4){
               $num1_49 = $num['andicapD'];
            }
            $resultA[$i]['ra'] -= $num1_49;
        }
        $nums = model("pancha")->findtm();
        foreach ($resultA as $key => $items) {
             if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
                if($items['bets']==52 || $items['bets']==53){
                   $num1_49 = $nums[0]['andicapB']; 
                }
                if($items['bets']==54 || $items['bets']==55){
                   $num1_49 = $nums[1]['andicapB']; 
                }
                if($items['bets']==56 || $items['bets']==57){
                   $num1_49 = $nums[2]['andicapB'];  
                }
            }
            if($andicap==3){
                if($items['bets']==52 || $items['bets']==53){
                   $num1_49 = $nums[0]['andicapC']; 
                }
                if($items['bets']==54 || $items['bets']==55){
                   $num1_49 = $nums[1]['andicapC']; 
                }
                if($items['bets']==56 || $items['bets']==57){
                   $num1_49 = $nums[2]['andicapC'];  
                }
            }
            if($andicap==4){
               if($items['bets']==52 || $items['bets']==53){
                   $num1_49 = $nums[0]['andicapD']; 
                }
                if($items['bets']==54 || $items['bets']==55){
                   $num1_49 = $nums[1]['andicapD']; 
                }
                if($items['bets']==56 || $items['bets']==57){
                   $num1_49 = $nums[2]['andicapD'];  
                }
            }
            if($resultA[$key]['ra']<$num1_49){
                $resultA[$key]['ra'] = $items['ra'];
            }else{
                $resultA[$key]['ra'] -= $num1_49;
            }
        }
        $announce = model('announce')->findstatus(2);
        $qishu = model('openplate')->findqishu();
        $this->assign('datetime',$datetime);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        // 盘口Characters a;
        $this->assign('a',$andicap);
        $this->assign('Characters',$Characters);
        $this->assign('orders',$orders);
        $this->assign('user',$user);
        $this->assign('resultA',$resultA);
        $this->assign('s',$s);
        // echo(time()-$stime);
        // mp($user);
        return $this->fetch(); 
    }

    //特码b
    function members1($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>24]);
        $s = $this->panduanplate();
        $num1_49 = 0;
        $orders = model('Orders')->findsid(session('userid'));
                foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $resultB = model("rate")->findrateB();
        $resultA = model("rate")->findrateX();
        $num = model("pancha")->findtm();
        // mp($orders);
        foreach ($resultA as $key => $items) {
             if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
                if($items['bets']==52 || $items['bets']==53){
                   $num1_49 = $num[0]['andicapB']; 
                }
                if($items['bets']==54 || $items['bets']==55){
                   $num1_49 = $num[1]['andicapB']; 
                }
                if($items['bets']==56 || $items['bets']==57){
                   $num1_49 = $num[2]['andicapB'];  
                }
            }
            if($andicap==3){
                if($items['bets']==52 || $items['bets']==53){
                   $num1_49 = $num[0]['andicapC']; 
                }
                if($items['bets']==54 || $items['bets']==55){
                   $num1_49 = $num[1]['andicapC']; 
                }
                if($items['bets']==56 || $items['bets']==57){
                   $num1_49 = $num[2]['andicapC'];  
                }
            }
            if($andicap==4){
               if($items['bets']==52 || $items['bets']==53){
                   $num1_49 = $num[0]['andicapD']; 
                }
                if($items['bets']==54 || $items['bets']==55){
                   $num1_49 = $num[1]['andicapD']; 
                }
                if($items['bets']==56 || $items['bets']==57){
                   $num1_49 = $num[2]['andicapD'];  
                }
            }
            if($resultA[$key]['ra']<$num1_49){
                $resultA[$key]['ra'] = $items['ra'];
            }else{
                $resultA[$key]['ra'] -= $num1_49;
            }
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('s',$s);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('resultX',$resultA);
        $this->assign('a',$andicap);
        $this->assign('Characters',$Characters);
        $this->assign('orders',$orders);
        $this->assign('user',$user);
        $this->assign('resultA',$resultB);
        return $this->fetch(); 
    }
    
    // 正码
    function member2($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>25]);
        $s = $this->openzmplate();
        $datename = model('openplate')->finddatename();
         $announce = model('announce')->findstatus(2);
        $stime = time();
        $num1_49 = 0;
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $a = $andicap;
        $resultrate = model("rate")->finds(1,2);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $num5 = model("pancha")->findpan(5);
        $num6 = model("pancha")->findpan(6);
        $num7 = model("pancha")->findpan(7);
        $result = model("rate")->findzm();
        foreach ($result as $key => $item) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               if($item['bets']==58 || $item['bets']==59){
                   $num1_49 = $num6['andicapB']; 
                }
                if($item['bets']==60 || $item['bets']==61){
                   $num1_49 = $num7['andicapB']; 
                }
            }
            if($andicap==3){
               if($item['bets']==58 || $item['bets']==59){
                   $num1_49 = $num6['andicapC']; 
                }
                if($item['bets']==60 || $item['bets']==61){
                   $num1_49 = $num7['andicapC']; 
                }
            }
            if($andicap==4){
               if($item['bets']==58 || $item['bets']==59){
                   $num1_49 = $num6['andicapD']; 
                }
                if($item['bets']==60 || $item['bets']==61){
                   $num1_49 = $num7['andicapD']; 
                }
            }
            if($result[$key]['ra']<$num1_49){
                $result[$key]['ra'] = $item['ra'];
            }else{
                $result[$key]['ra'] -= $num1_49;
            }
        }
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               $num1_49 = $num5['andicapB'];
            }
            if($andicap==3){
               $num1_49 = $num5['andicapC'];
            }
            if($andicap==4){
               $num1_49 = $num5['andicapD'];
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }
        $this->assign('s',$s);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('result',$result);
        $this->assign('orders',$orders);
        $this->assign('a',$a);
        $this->assign('res',$resultrate);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        // mp($resultrate);
        // echo(time()-$stime);
        return $this->fetch(); 
    }
    // 正特码
    function member3($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>26]);
        $s = $this->openzmplate();
        $num1_49 = 0;
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $a = $andicap;
        $resultrate = model("rate")->finds(1,3);
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $num7 = model("pancha")->findpan(24);
         foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               $num1_49 = $num7['andicapB'];
            }
            if($andicap==3){
               $num1_49 = $num7['andicapC'];
            }
            if($andicap==4){
               $num1_49 = $num7['andicapD'];
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        $this->assign('s',$s);
        return $this->fetch(); 
    }
    // 正码1-6
    function member4($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>27]);
        $s = $this->openzmplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $num1_49 = 0;
        $resultrate = model("rate")->finds(1,4);
        $num12 = model("pancha")->findpan(10);
        $num34 = model("pancha")->findpan(11);
        $num567 = model("pancha")->findpan(12);
        $num89 = model("pancha")->findpan(13);
        for($i=0;$i<6;$i++){
            $x1[] = 1 + 9*$i;
            $x2[] = 2 + 9*$i;
            $x3[] = 3 + 9*$i;
            $x4[] = 4 + 9*$i;
            $x5[] = 5 + 9*$i;
            $x6[] = 6 + 9*$i;
            $x7[] = 7 + 9*$i;
            $x8[] = 8 + 9*$i;
            $x9[] = 9 + 9*$i;
        }
        foreach ($resultrate as $key => $v) {
            // mp($v['bets']);
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
                for ($z=0; $z < 6; $z++) { 
                    if($v['bets']==$x1[$z]||$v['bets']==$x2[$z]){
                        $num1_49 = $num12['andicapB'];
                    }
                    if($v['bets']==$x3[$z]||$v['bets']==$x4[$z]){
                        $num1_49 = $num34['andicapB'];
                    }
                    if($v['bets']==$x5[$z]||$v['bets']==$x6[$z]||$v['bets']==$x7[$z]){
                        $num1_49 = $num567['andicapB'];
                    }
                    if($v['bets']==$x8[$z]||$v['bets']==$x9[$z]){
                        $num1_49 = $num89['andicapB'];
                    }
                }
            }
            if($andicap==3){
                for ($z=0; $z < 6; $z++) { 
                    if($v['bets']==$x1[$z]||$v['bets']==$x2[$z]){
                        $num1_49 = $num12['andicapC'];
                    }
                    if($v['bets']==$x3[$z]||$v['bets']==$x4[$z]){
                        $num1_49 = $num34['andicapC'];
                    }
                    if($v['bets']==$x5[$z]||$v['bets']==$x6[$z]||$v['bets']==$x7[$z]){
                        $num1_49 = $num567['andicapC'];
                    }
                    if($v['bets']==$x8[$z]||$v['bets']==$x9[$z]){
                        $num1_49 = $num89['andicapC'];
                    }
                }
            }
            if($andicap==4){
               for ($z=0; $z < 6; $z++) { 
                    if($v['bets']==$x1[$z]||$v['bets']==$x2[$z]){
                        $num1_49 = $num12['andicapD'];
                    }
                    if($v['bets']==$x3[$z]||$v['bets']==$x4[$z]){
                        $num1_49 = $num34['andicapD'];
                    }
                    if($v['bets']==$x5[$z]||$v['bets']==$x6[$z]||$v['bets']==$x7[$z]){
                        $num1_49 = $num567['andicapD'];
                    }
                    if($v['bets']==$x8[$z]||$v['bets']==$x9[$z]){
                        $num1_49 = $num89['andicapD'];
                    }
                }
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    // 正码过关
    function member5($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>28]);
        $s = $this->openzmplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        // mp($orders);
        $resultrate = model("rate")->finds(1,5);
        $num = model("pancha")->findpan(34);
        $num1_49 = 0;
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               $num1_49 = $num['andicapB'];
            }
            if($andicap==3){
               $num1_49 = $num['andicapC'];
            }
            if($andicap==4){
               $num1_49 = $num['andicapD'];
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    // 特码生肖色波头尾数 
    function member6($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>29]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        $resultrate = model("rate")->finds(1,6);
        $result = model("rate")->findrate62_63();
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $num8 = model("pancha")->findpan(8);//特码色波
        $num9 = model("pancha")->findpan(9);//特码生肖
        $num28 = model("pancha")->findpan(28);//特码头数
        $num29 = model("pancha")->findpan(29);//特码尾数
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
                if($v['bets']<13){
                    $num1_49 = $num9['andicapB'];
                }
                if($v['bets']>12&&$v['bets']<18){
                   $num1_49 = $num28['andicapB']; 
                }
                if($v['bets']>17&&$v['bets']<28){
                    $num1_49 = $num29['andicapB']; 
                }
                if($v['bets']>27){
                    $num1_49 = $num8['andicapB'];
                }
            }
            if($andicap==3){
               if($v['bets']<13){
                    $num1_49 = $num9['andicapC'];
                }
                if($v['bets']>12&&$v['bets']<18){
                   $num1_49 = $num28['andicapC']; 
                }
                if($v['bets']>17&&$v['bets']<28){
                    $num1_49 = $num29['andicapC']; 
                }
                if($v['bets']>27){
                    $num1_49 = $num8['andicapC'];
                }
            }
            if($andicap==4){
               if($v['bets']<13){
                    $num1_49 = $num9['andicapD'];
                }
                if($v['bets']>12&&$v['bets']<18){
                   $num1_49 = $num28['andicapD']; 
                }
                if($v['bets']>17&&$v['bets']<28){
                    $num1_49 = $num29['andicapD']; 
                }
                if($v['bets']>27){
                    $num1_49 = $num8['andicapD'];
                }
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('result',$result);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        // mp($num8);
        // 
        $ss = getSSNameArray();
        $this->assign("ss",$ss);
        return $this->fetch(); 
    }
    // 连码
    function member7($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>30]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $resultrate = model("rate")->finds(1,7);
        $num18 = model("pancha")->findpan(18);//三全中
        $num19 = model("pancha")->findpan(19);//三中二
        $num20 = model("pancha")->findpan(20);//二全中
        $num21 = model("pancha")->findpan(21);//二中特
        $num22 = model("pancha")->findpan(22);//特串
        if($andicap==2){
                if($v['colums']==1){
                    $num1_49 = $num18['andicapB'];
                }
                if($v['colums']==2){
                    $num1_49 = $num19['andicapB'];
                }
                if($v['colums']==3){
                    $num1_49 = $num20['andicapB'];
                }
                if($v['colums']==4){
                    $num1_49 = $num21['andicapB'];
                }
                if($v['colums']==5){
                    $num1_49 = $num22['andicapB'];
                }
            }
            if($andicap==3){
               if($v['colums']==1){
                    $num1_49 = $num18['andicapC'];
                }
                if($v['colums']==2){
                    $num1_49 = $num19['andicapC'];
                }
                if($v['colums']==3){
                    $num1_49 = $num20['andicapC'];
                }
                if($v['colums']==4){
                    $num1_49 = $num21['andicapC'];
                }
                if($v['colums']==5){
                    $num1_49 = $num22['andicapC'];
                }
            }
            if($andicap==4){
               if($v['colums']==1){
                    $num1_49 = $num18['andicapD'];
                }
                if($v['colums']==2){
                    $num1_49 = $num19['andicapD'];
                }
                if($v['colums']==3){
                    $num1_49 = $num20['andicapD'];
                }
                if($v['colums']==4){
                    $num1_49 = $num21['andicapD'];
                }
                if($v['colums']==5){
                    $num1_49 = $num22['andicapD'];
                }
            }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        // $zodiac = model('zodiac')->findall();//获取所有的生肖的号码和名字
        $zodiac = getSSNameArray();
        $zodiac = json_encode($zodiac);
        // mp($zodiac);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        $this->assign('zodiac',$zodiac);
        // mp($resultrate);
        return $this->fetch(); 
    }
    // 半波
    function member8($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>31]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $resultrate = model("rate")->finds(1,8);
        $num = model("pancha")->findpan(14);
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               $num1_49 = $num['andicapB'];
            }
            if($andicap==3){
               $num1_49 = $num['andicapC'];
            }
            if($andicap==4){
               $num1_49 = $num['andicapD'];
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }$datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        // mp($resultrate);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    // 正肖总肖七码
    function member9($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>32]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $resultrate = model("rate")->finds(1,9);
        $num30 = model("pancha")->findpan(30);//总肖
        $num32 = model("pancha")->findpan(32);//正肖
        $num49 = model("pancha")->findpan(49);//七码
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
                if($v['bets']<13){
                    $num1_49 = $num32['andicapB'];
                }
                if($v['bets']>12&&$v['bets']<19){
                    $num1_49 = $num30['andicapB'];
                }
                if($v['bets']>18){
                    $num1_49 = $num49['andicapB'];
                }
            }
            if($andicap==3){
               if($v['bets']<13){
                    $num1_49 = $num32['andicapC'];
                }
                if($v['bets']>12&&$v['bets']<19){
                    $num1_49 = $num30['andicapC'];
                }
                if($v['bets']>18){
                    $num1_49 = $num49['andicapC'];
                }
            }
            if($andicap==4){
               if($v['bets']<13){
                    $num1_49 = $num32['andicapD'];
                }
                if($v['bets']>12&&$v['bets']<19){
                    $num1_49 = $num30['andicapD'];
                }
                if($v['bets']>18){
                    $num1_49 = $num49['andicapD'];
                }
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        // mp($resultrate);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $ss = getSSNameArray();
        $this->assign("ss",$ss);
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    // 连肖
    function member10($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>33]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $resultrate = model("rate")->finds(1,10);
        $num = model("pancha")->findpan(33);
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               $num1_49 = $num['andicapB'];
            }
            if($andicap==3){
               $num1_49 = $num['andicapC'];
            }
            if($andicap==4){
               $num1_49 = $num['andicapD'];
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }$datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        // mp($resultrate);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    // 尾数连
    function member11($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>34]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $resultrate = model("rate")->finds(1,11);
        $num = model("pancha")->findpan(48);
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               $num1_49 = $num['andicapB'];
            }
            if($andicap==3){
               $num1_49 = $num['andicapC'];
            }
            if($andicap==4){
               $num1_49 = $num['andicapD'];
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }$datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
         // mp($resultrate);
        return $this->fetch(); 
    }
    // 多肖
    function member12($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>35]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $resultrate = model("rate")->finds(1,12);
        $num = model("pancha")->findpan(15);
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               $num1_49 = $num['andicapB'];
            }
            if($andicap==3){
               $num1_49 = $num['andicapC'];
            }
            if($andicap==4){
               $num1_49 = $num['andicapD'];
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }$datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
          // mp($resultrate);
        return $this->fetch(); 
    }
    // 一肖尾数七色波
    function member13($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>36]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $resultrate = model("rate")->finds(1,13);
        $num16 = model("pancha")->findpan(16);//一肖中
        $num47 = model("pancha")->findpan(47);//一肖不中
        $num23 = model("pancha")->findpan(23);//七色波
        $num17 = model("pancha")->findpan(17);//尾数
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
                if($v['bets']<13){
                    if($v['colums']==1){
                    $num1_49 = $num16['andicapB'];
                   }
                   if($v['colums']==2){
                     $num1_49 = $num47['andicapB'];
                   }
                }
                if($v['bets']>12&&$v['bets']<23){
                   $num1_49 = $num17['andicapB']; 
                }
                if($v['bets']>22){
                    $num1_49 = $num23['andicapB']; 
                }  
               
            }
            if($andicap==3){
               if($v['bets']<13){
                    if($v['colums']==1){
                    $num1_49 = $num16['andicapC'];
                   }
                   if($v['colums']==2){
                     $num1_49 = $num47['andicapC'];
                   }
                }
                if($v['bets']>12&&$v['bets']<23){
                   $num1_49 = $num17['andicapD']; 
                }
                if($v['bets']>22){
                    $num1_49 = $num23['andicapD']; 
                }  
            }
            if($andicap==4){
               if($v['bets']<13){
                    if($v['colums']==1){
                    $num1_49 = $num16['andicapD'];
                   }
                   if($v['colums']==2){
                     $num1_49 = $num47['andicapD'];
                   }
                }
                if($v['bets']>12&&$v['bets']<23){
                   $num1_49 = $num17['andicapD']; 
                }
                if($v['bets']>22){
                    $num1_49 = $num23['andicapD']; 
                }  
            }
           if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $ss = getSSNameArray();
        $this->assign("ss",$ss);
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
         // mp($resultrate);
        return $this->fetch(); 
    }
    // 全不中
    function member14($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>37]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $resultrate = model("rate")->finds(1,14);
        $num35 = model("pancha")->findpan(35);//5
        $num36 = model("pancha")->findpan(36);//6
        $num37 = model("pancha")->findpan(37);//7
        $num38 = model("pancha")->findpan(38);//8
        $num39 = model("pancha")->findpan(39);//9
        $num40 = model("pancha")->findpan(40);//10
        $num41 = model("pancha")->findpan(41);//11
        $num42 = model("pancha")->findpan(42);//12
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
               if($v['colums']==1){
                    $num1_49 = $num35['andicapB'];
                }
                if($v['colums']==2){
                    $num1_49 = $num36['andicapB'];
                }
                if($v['colums']==3){
                    $num1_49 = $num37['andicapB'];
                }
                if($v['colums']==4){
                    $num1_49 = $num38['andicapB'];
                }
                if($v['colums']==5){
                    $num1_49 = $num39['andicapB'];
                }
                if($v['colums']==6){
                    $num1_49 = $num40['andicapB'];
                }
                if($v['colums']==7){
                    $num1_49 = $num41['andicapB'];
                }
                if($v['colums']==8){
                    $num1_49 = $num42['andicapB'];
                }
            }
            if($andicap==3){
               if($v['colums']==1){
                    $num1_49 = $num35['andicapC'];
                }
                if($v['colums']==2){
                    $num1_49 = $num36['andicapC'];
                }
                if($v['colums']==3){
                    $num1_49 = $num37['andicapC'];
                }
                if($v['colums']==4){
                    $num1_49 = $num38['andicapC'];
                }
                if($v['colums']==5){
                    $num1_49 = $num39['andicapC'];
                }
                if($v['colums']==6){
                    $num1_49 = $num40['andicapC'];
                }
                if($v['colums']==7){
                    $num1_49 = $num41['andicapC'];
                }
                if($v['colums']==8){
                    $num1_49 = $num42['andicapC'];
                }
            }
            if($andicap==4){
               if($v['colums']==1){
                    $num1_49 = $num35['andicapD'];
                }
                if($v['colums']==2){
                    $num1_49 = $num36['andicapD'];
                }
                if($v['colums']==3){
                    $num1_49 = $num37['andicapD'];
                }
                if($v['colums']==4){
                    $num1_49 = $num38['andicapD'];
                }
                if($v['colums']==5){
                    $num1_49 = $num39['andicapD'];
                }
                if($v['colums']==6){
                    $num1_49 = $num40['andicapD'];
                }
                if($v['colums']==7){
                    $num1_49 = $num41['andicapD'];
                }
                if($v['colums']==8){
                    $num1_49 = $num42['andicapD'];
                }
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    // 多中一
    function member15($andicap=1){
        model('user')->where('id',session('userid'))->update(['addrs'=>37]);
        $s = $this->panduanplate();
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $resultrate = model("rate")->finds(1,15);
        $num43 = model("pancha")->findpan(43);//3
        $num44 = model("pancha")->findpan(44);//4
        $num45 = model("pancha")->findpan(45);//5
        $num46 = model("pancha")->findpan(46);//6
        foreach ($resultrate as $key => $v) {
            if($andicap==1){
               $num1_49 = 0;
            }
            if($andicap==2){
                if($v['colums']==1){
                    $num1_49 = $num43['andicapB'];
                }
                if($v['colums']==2){
                    $num1_49 = $num44['andicapB'];
                }
                if($v['colums']==3){
                    $num1_49 = $num45['andicapB'];
                }
                if($v['colums']==4){
                    $num1_49 = $num46['andicapB'];
                }
            }
            if($andicap==3){
               if($v['colums']==1){
                    $num1_49 = $num43['andicapC'];
                }
                if($v['colums']==2){
                    $num1_49 = $num44['andicapC'];
                }
                if($v['colums']==3){
                    $num1_49 = $num45['andicapC'];
                }
                if($v['colums']==4){
                    $num1_49 = $num46['andicapC'];
                }
            }
            if($andicap==4){
               if($v['colums']==1){
                    $num1_49 = $num43['andicapD'];
                }
                if($v['colums']==2){
                    $num1_49 = $num44['andicapD'];
                }
                if($v['colums']==3){
                    $num1_49 = $num45['andicapD'];
                }
                if($v['colums']==4){
                    $num1_49 = $num46['andicapD'];
                }
            }
            if($resultrate[$key]['ra']<$num1_49){
                $resultrate[$key]['ra'] = $v['ra'];
            }else{
                $resultrate[$key]['ra'] -= $num1_49;
            }
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('res',$resultrate);
        $a = $andicap;
        $this->assign('s',$s);
        $this->assign('a',$a);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    // 密码设定
    function passchange(){
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    // 开奖记录
    function record(){
        $user = model('user')->finds(session('userid'));
        $Character = $user['andicap'];
        $Characters = $this->charactersubstr($Character);
        $orders = model('Orders')->findsid(session('userid'));
        foreach($orders as $key =>$it){
            $orders[$key]['bets'] = inserpankous($it["bet"],$it["colums"],$it["bets"],$it["name"]);
        }
        $datename = model('openplate')->finddatename();
        $announce = model('announce')->findstatus(2);
       $r = model('result')->findall();

        foreach ($r as $key => $vj) {
            $Zseven = $vj['Zseven'];
            $seven = $Zseven . "";
            $arr = str_split($seven, 1);
            if (count($arr) > 1) {
                $arr0 = intval($arr[0]);

                $arr1 = intval($arr[1]);

                if (($arr1 + $arr0) % 2 == 0) {
                    $r[$key]['hs1'] = "双";
                } else {
                    $r[$key]['hs1'] = "单";
                }
                if (($arr1 + $arr0) > 6) {
                    $r[$key]['hs2'] = "大";
                } else {
                    $r[$key]['hs2'] = "小";
                }
                 if($Zseven==49){
                    $r[$key]['hs1'] = "和";
                    $r[$key]['hs2'] = "和";
                }
            } else {
                $arr1 = intval($arr[0]);
                if (($arr1) % 2 == 0) {
                    $r[$key]['hs1'] = "双";
                } else {
                    $r[$key]['hs1'] = "单";
                }
                if (($arr1) > 6) {
                    $r[$key]['hs2'] = "大";
                } else {
                    $r[$key]['hs2'] = "小";
                }
                if($Zseven==49){
                    $r[$key]['hs1'] = "和";
                    $r[$key]['hs2'] = "和";
                }
            }

            if ($Zseven % 2 == 0) {
                $r[$key]['tm1'] = "双";
            } else {
                $r[$key]['tm1'] = "单";
            }

            if ($Zseven > 24 && $Zseven!=49) {
                $r[$key]['tm2'] = "大";
            } else if($Zseven ==49){
                $r[$key]['tm2'] = "和";
            } else{
                $r[$key]['tm2'] = "小";
            }
            $zf = $vj['Zone'] + $vj['Ztwo'] + $vj['Zthree'] + $vj['Zfour'] + $vj['Zfive'] + $vj['Zsix'] + $vj['Zseven'];
            $r[$key]['zf'] = $zf;
            if ($zf > 174) {
                $r[$key]['zf2'] = "大";
            } else {
                $r[$key]['zf2'] = "小";
            }
            if ($zf % 2 == 0) {
                $r[$key]['zf1'] = "双";
            } else {
                $r[$key]['zf1'] = "单";
            }
            $z1 = getSSNameByNum($vj['Zone']);
            $z2 = getSSNameByNum($vj['Ztwo']);
            $z3 = getSSNameByNum($vj['Zthree']);
            $z4 = getSSNameByNum($vj['Zfour']);
            $z5 = getSSNameByNum($vj['Zfive']);
            $z6 = getSSNameByNum($vj['Zsix']);
            $z7 = getSSNameByNum($Zseven);
            $ztm = array($z1, $z2, $z3, $z4, $z5, $z6, $z7);
            $ztm = $this->formatArray($ztm);
            $zx = count($ztm);
            $r[$key]['zx1'] = $zx;
            if ($zx % 2 == 0) {
                $r[$key]['zx2'] = "双";
            } else {
                $r[$key]['zx2'] = "单";
            }
            $r[$key]['sx'] = $z7;
            if ($Zseven == 1 || $Zseven == 2 || $Zseven == 7 || $Zseven == 8 || $Zseven == 12 || $Zseven == 13 || $Zseven == 18 || $Zseven == 19 || $Zseven == 23 || $Zseven == 24 || $Zseven == 29 || $Zseven == 30 || $Zseven == 34 || $Zseven == 35 || $Zseven == 40 || $Zseven == 45 || $Zseven == 46) {
                $r[$key]['sb'] = "红色";
            } else if ($Zseven == 5 || $Zseven == 6 || $Zseven == 11 || $Zseven == 16 || $Zseven == 17 || $Zseven == 21 || $Zseven == 22 || $Zseven == 27 || $Zseven == 28 || $Zseven == 32 || $Zseven == 33 || $Zseven == 38 || $Zseven == 39 || $Zseven == 43 || $Zseven == 44 || $Zseven == 49) {
                $r[$key]['sb'] = "绿色";
            } else {
                $r[$key]['sb'] = "蓝色";
            }

        }
        // mp($r);
        $this->assign("kj",$r);
        $this->assign('opename',$datename);
        $this->assign('announce',$announce);
        $this->assign('orders',$orders);
        $this->assign('Characters',$Characters);
        $this->assign('user',$user);
        return $this->fetch(); 
    }
    function formatArray($array){
        // 合拼数组重复的
        sort($array);
        $tem = "";
        $temarray = array();
        $j = 0;
        for($i=0;$i<count($array);$i++){
            if($array[$i]!=$tem){
                $temarray[$j] = $array[$i];
                $j++;
            }
            $tem = $array[$i];
        }
        return $temarray;
    }
}
